package com.hz.pay.center.service.strategy.impl;

import com.pay.common.enums.PayWayEnum;
import com.hz.pay.center.factory.PayFactory;
import com.hz.pay.center.model.PaySerialInfo;
import com.pay.common.resp.NetBankPayRespData;
import com.hz.pay.center.service.strategy.IStrategyPayService;
import com.hz.pay.center.utils.WechatUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 微信扫码支付的实现类
 */
@Service  //                                                                     初始化bean的执行
public class WechatQrCodeStrategyPayServiceImpl implements IStrategyPayService, InitializingBean {

    @Autowired
    private WechatUtil wechatUtil;

    private Logger logger = LoggerFactory.getLogger(WechatQrCodeStrategyPayServiceImpl.class);


    @Override
    public NetBankPayRespData payment(PaySerialInfo paySerialInfo) {
        logger.info("###########微信扫码支付#############");
        wechatUtil.wechatQrCodePay();

        return null;
    }


    /**
     * bean 初始化的时候执行这个方式
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {

        logger.info("###########初始化WechatQrCodeStrategyPayServiceImpl#############");

        PayFactory.concurrentHashMap.put(PayWayEnum.WECHAT_QRCODE_PAY.getCode(),this);


    }
}
